import axios from '@/libs/api.request'
import config from '@/../src/config/index';

const defaultWmsUrl = process.env.NODE_ENV === 'development'
    ? config.wmsUrl.dev
    : process.env.VUE_APP_MODE === 'testEnvironment'
        ? config.wmsUrl.dev
        :  process.env.VUE_APP_MODE === 'temporary'
            ? config.wmsUrl.temporary
            :  process.env.VUE_APP_MODE === 'prod'
                ? config.wmsUrl.pro
                : config.wmsUrl.dev;

export function getStgTypData (query) {
  return axios.request({
    url: '/api/wms_stg_typ/page',
    method: 'post',
    data: query
  })
}
// 获取所有库区
export function getAllStgData() {
  return axios.request({
    url: '/api/wms_stg_typ/getAllStgData',
    method: 'post'
  })
}
export function updateStgTypData (query) {
  return axios.request({
    url: '/api/wms_stg_typ',
    method: 'put',
    data: query
  })
}
export function deleteItem (query) {
  return axios.request({
    url: '/api/wms_stg_typ',
    method: 'delete',
    data: query
  })
}
export function saveStgTypData (query) {
  return axios.request({
    url: '/api/wms_stg_typ',
    method: 'post',
    data: query
  })
}
export function getAllType (dictType, wmsUrl= defaultWmsUrl) {
  return axios.request({
    url: wmsUrl + '/api/dictionary/' + dictType + '/list',
    method: 'get',
    parameter: {
      type: 'WMS'
    }
  })
}
export function updateByDictType (query) {
  return axios.request({
    url: '/api/dictionary/updateDictByDictType',
    method: 'post',
    data: query
  })
}
// 获取当前agvStg类型是否有默认库
export function getDataByAgvStg (query) {
  return axios.request({
    url: '/api/wms_stg_typ/selectByAgvStg',
    method: 'post',
    data: query
  })
}
// 获取所有物理区
export function getAllPhysical () {
  return axios.request({
    url: '/api/ccsMap/getAllPhysical',
    method: 'get'
  })
}
